package com.game.centerserver.config;

import cn.dev33.satoken.exception.NotLoginException;
import com.game.centerserver.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created with IntelliJ IDEA.
 * 全局异常处理器
 * @Author: tian
 * @Date: 2024/11/19/17:58
 * @Description:
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    // 全局异常拦截
    @ExceptionHandler
    public Result handlerException(Exception e) {
        if (e instanceof NotLoginException){
            return Result.fail("请登录");
        }else{
            e.printStackTrace();
            return Result.fail("服务器错误");
        }
    }
}

